package de.java.shortys.utils.format;

import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.util.Calendar;
import java.util.Locale;

public final class FormatUtils {

	public static String getCurrencyOutput(Locale locale, Double value) {
		// DecimalFormat decimalFormat = new
		// DecimalFormat("#,###,###,##0.00 \u00A4");
		return NumberFormat.getCurrencyInstance(locale).format(value);
	}

	public static String getDoubleOutput(Locale locale, Double value) {
		return getDoubleOutput(locale, value, 1);
	}

	public static String getDoubleOutput(Locale locale, Double value, int nachkommastellenMindestens) {
		DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(locale);
		final StringBuffer format = new StringBuffer("0.");
		for (int i = 0; i < nachkommastellenMindestens; i++) {
			format.append("0");
		}
		DecimalFormat decimalFormat = new DecimalFormat(format.toString());
		decimalFormat.setDecimalFormatSymbols(decimalFormatSymbols);
		return decimalFormat.format(value);
	}

	public static String getCalendarOutput(Locale locale, Calendar value, int format) {
		return DateFormat.getDateInstance(format, locale).format(value.getTime());

	}

	private FormatUtils() {
		// Empty
	}
}
